home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / parallel-C disk ^1.adf / STDIO.H < prev    next >
C/C++ Source or Header  |  1997-12-31  |  1KB  |  48 lines

  1. /* stdio.h   version 2.2.0   standard I/O functions */
  2.  
  3. /* Rev 002 18-SEP-87 IAY     upped _NFILE to 22 to cover MS-DOS limit with
  4.                              a bit to spare */
  5. /* Rev 001 16-SEP-86 ADC     added O_BINARY and O_TEXT for Beta Release */
  6.  
  7. #define O_BINARY 4
  8. #define O_TEXT   8
  9.  
  10. #define BUFSIZ   512
  11. #define _NFILE   22 /* #files that can be handled */
  12.  
  13. typedef struct _iobuf {
  14.    char *_ptr;      /* next character position */
  15.    int  _cnt;       /* number of characters left */
  16.    char *_base;     /* location of buffer */
  17.    int  _flag;      /* mode of file access */
  18.    int  _file;      /* file descriptor */
  19. } FILE;
  20.  
  21. #define   fileno(p) (p)->_file
  22.  
  23. extern FILE _iob[_NFILE];
  24.  
  25. #define   stdin     (&_iob[0])
  26. #define   stdout    (&_iob[1])
  27. #define   stderr    (&_iob[2])
  28.  
  29. #define   _IOREAD   01   /* file open for reading */
  30. #define   _IOWRT    02   /* file open for writing */
  31. #define   _IORW     04
  32. #define   _IONBF    010  /* file is unbuffered */
  33. #define   _IOSTRG   020
  34. #define   _IOMYBUF  040
  35. #define   _IOEOF    0100
  36. #define   _IOERR    0200
  37.  
  38. #define   NULL      0
  39. #define   EOF       (-1)
  40.  
  41. #define   feof(p)   ((p)->_flag&_IOEOF)
  42. #define   ferror(p) ((p)->_flag&_IOERR)
  43. #define   getc(p)   (--(p)->_cnt>=0?*(p)->_ptr++:_filbuf(p))
  44. #define   putc(x,p) (--(p)->_cnt>=0?*(p)->_ptr++=(x):_flsbuf((x),p))
  45.  
  46. #define   getchar()      getc(stdin)
  47. #define   putchar(x)     putc(x,stdout)
  48.